﻿//-----------------------------------------------------------------------
// <copyright file="NewVersionViewModel.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 
namespace ChatBox.UI.Windows.NewVersion
{
    using System;
    using System.Windows.Input;

    using ChatBox.UI.Commands;
    using ChatBox.UI.ViewModels;

    /// <summary>
    /// View model for the "New Version" Window
    /// </summary>
    public class NewVersionViewModel : WindowViewModel
    {
        /// <summary>
        /// Command for clicking on a link
        /// </summary>
        private readonly StartUriCommand linkClick;

        /// <summary>
        /// Command to close the window
        /// </summary>
        private readonly WindowCloseCommand closeCommand;
        
        /// <summary>
        /// The window title text
        /// </summary>
        private string title;

        /// <summary>
        /// the text to show for current version
        /// </summary>
        private string currentVersionText;

        /// <summary>
        /// the text of the download link
        /// </summary>
        private string downloadLinkText;

        /// <summary>
        /// the download link target
        /// </summary>
        private Uri downloadLink;

        /// <summary>
        /// The homepage link text
        /// </summary>
        private string homepageLinkText;

        /// <summary>
        /// the homepage link url
        /// </summary>
        private Uri homepageLink;

        /// <summary>
        /// Initializes a new instance of the NewVersionViewModel class
        /// </summary>
        /// <param name="linkClick">the link click command</param>
        /// <param name="closeCommand">the command to close the window</param>
        public NewVersionViewModel(StartUriCommand linkClick, WindowCloseCommand closeCommand)
        {
            this.linkClick = linkClick;
            this.closeCommand = closeCommand;
        }

        /// <summary>
        /// Gets or sets the window title
        /// </summary>
        public string Title
        {
            get
            {
                return this.title;
            }

            set
            {
                if (this.title != value)
                {
                    this.title = value;
                    OnPropertyChanged("Title");
                }
            }
        }

        /// <summary>
        /// Gets or sets the display text for the current version 
        /// </summary>
        public string CurrentVersionText
        {
            get
            {
                return this.currentVersionText;
            }

            set
            {
                if (this.currentVersionText != value)
                {
                    this.currentVersionText = value;
                    OnPropertyChanged("CurrentVersionText");
                }
            }
        }

        /// <summary>
        /// Gets or sets the display text for the download 
        /// </summary>
        public string DownloadLinkText
        {
            get
            {
                return this.downloadLinkText;
            }

            set
            {
                if (this.downloadLinkText != value)
                {
                    this.downloadLinkText = value;
                    OnPropertyChanged("DownloadLinkText");
                }
            }
        }

        /// <summary>
        /// Gets or sets the link for the download
        /// </summary>
        public Uri DownloadLink
        {
            get
            {
                return this.downloadLink;
            }

            set
            {
                if (this.downloadLink != value)
                {
                    this.downloadLink = value;
                    OnPropertyChanged("DownloadLink");
                }
            }
        }

        /// <summary>
        /// Gets or sets the display text for the home page 
        /// </summary>
        public string HomepageLinkText
        {
            get
            {
                return this.homepageLinkText;
            }

            set
            {
                if (this.homepageLinkText != value)
                {
                    this.homepageLinkText = value;
                    OnPropertyChanged("HomepageLinkText");
                }
            }
        }

        /// <summary>
        /// Gets or sets the link for the download
        /// </summary>
        public Uri HomepageLink
        {
            get
            {
                return this.homepageLink;
            }

            set
            {
                if (this.homepageLink != value)
                {
                    this.homepageLink = value;
                    OnPropertyChanged("HomepageLink");
                }
            }
        }

        /// <summary>
        /// Gets the command for clicking on a link
        /// </summary>
        public ICommand LinkClick
        {
            get
            {
                return this.linkClick;
            }
        }

        /// <summary>
        /// Gets the command to close the window
        /// </summary>
        public ICommand CloseCommand
        {
            get
            {
                return this.closeCommand;
            }
        }
    }
}
